package  com.hpp.utils;

import java.io.Serializable;

/**
 * 日志基础信息类.
 */
public class MetaInfo implements Serializable {

    private static final String STATUS_DEF = "DEF";

    private static final long serialVersionUID = -198875474009728992L;

    private static final int BASE_NUMBER = 10000000;

    private static final int MAX_LENGTH = 22;

    private String uuid;

    private String method;

    private String status = STATUS_DEF;

    private long ftime;

    private long bid;

    public MetaInfo(String method) {
        this.method = method;
        ftime = System.currentTimeMillis();
        if (uuid == null) {
            long id = Thread.currentThread().getId();
            double math = Math.random();
            uuid = (long) (math * ftime) + "-" + id + "-" + (long) (math * id * BASE_NUMBER);
            if (uuid.length() > MAX_LENGTH) {
                uuid = uuid.substring(0, MAX_LENGTH);
            }
        }
    }

    public String getUuid() {
        return uuid;
    }

    public String getMethod() {
        return method;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public long getTime() {
        return System.currentTimeMillis() - ftime;
    }

    public long getBid() {
        return bid;
    }

    public void setBid(long bid) {
        this.bid = bid;
    }

}
